<?
function JSON_print($result, $child = false) 
{ 
 foreach($result as $key => $val) 
 { 
  $is_child = 0; 
  if(is_array($val)){ $AjaxReturn[] = JSON_print($val,true); $is_child++;} 
  else $AjaxReturn[] = $key . ': \'' . $val.'\''; 
  //else $AjaxReturn[] = '\'' . $key . '\' : \'' . $val.'\''; 
 } 

 $return_json = $is_child > 0? '"['.implode(', ',$AjaxReturn).']"' : '{'.implode(', ',$AjaxReturn).'}'; 
  
 if($child) return $return_json; 
 else print $return_json; 

 exit; 
} 
?>